#pragma once
#pragma warning(disable:4996)       // disable checked iterator errors http://msdn.microsoft.com/en-us/library/aa985965(VS.80).aspx 

//
// Copyright (C) 2011 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.101

#include <Macros.h>
#include <CoVector.h>
#include <CoMatrix.h>
#include <CoCube.h>
#include <ValueHelpers.h>
#include <Settings.h>

#include <gen/QL/Models/Marketmodels/Products/MultiProductOneStep.h>
#pragma unmanaged 
#include <ql\models\marketmodels\products\onestep\onestepoptionlets.hpp>
#include <boost/smart_ptr/detail/spinlock.hpp>
#pragma managed 

using namespace System;
using namespace QuantLib;
using namespace Cephei;

using namespace Cephei::QL::Models::Marketmodels;
using namespace Cephei::QL;
using namespace Cephei::QL::Models::Marketmodels::Products;
#undef HANDLE
#undef ABSTRACT
#undef STRUCT
namespace Cephei { namespace QL { namespace Models { namespace Marketmodels { namespace Products { namespace Onestep {
	//////////////////////////////////////////////////////////////////////////////////////////////
	// implementation of IOneStepOptionlets
	public ref class COneStepOptionlets : 
            public CMultiProductOneStep,
            public Cephei::QL::Models::Marketmodels::Products::Onestep::IOneStepOptionlets
	{
	protected: 
		boost::shared_ptr<QuantLib::OneStepOptionlets>* _ppOneStepOptionlets;
#ifdef HANDLE
		QuantLib::Handle<QuantLib::OneStepOptionlets>* _phOneStepOptionlets;
#endif
		Object^ _OneStepOptionletsOwner;     // reference to object that manages the storage for this object
	internal:
		COneStepOptionlets (Cephei::IVector<Double>^ rateTimes, Cephei::IVector<Double>^ accruals, Cephei::IVector<Double>^ paymentTimes, Cephei::IVector<Cephei::QL::IPayoff^>^ payoffs);
        COneStepOptionlets (boost::shared_ptr<QuantLib::OneStepOptionlets>& childNative, Object^ owner);
        COneStepOptionlets (QuantLib::OneStepOptionlets& childNative, Object^ owner);
        COneStepOptionlets (COneStepOptionlets^ copy);
        COneStepOptionlets (System::Type^ t);
#ifdef STRUCT
        COneStepOptionlets (QuantLib::OneStepOptionlets childNative);
#endif       
#ifdef HANDLE
		COneStepOptionlets (QuantLib::Handle<QuantLib::OneStepOptionlets>& childNative, Object^ owner);
		COneStepOptionlets (QuantLib::Handle<QuantLib::OneStepOptionlets> childNative);
#endif
		virtual ~COneStepOptionlets ();
		!COneStepOptionlets ();

	internal:
		QuantLib::OneStepOptionlets& GetReference ();
		boost::shared_ptr<QuantLib::OneStepOptionlets>& GetShared ();
		QuantLib::OneStepOptionlets* GetPointer ();
        void SetOneStepOptionlets (boost::shared_ptr<QuantLib::OneStepOptionlets> native)
        {
            if (_ppOneStepOptionlets != NULL)
                delete _ppOneStepOptionlets;
            _ppOneStepOptionlets = new boost::shared_ptr<QuantLib::OneStepOptionlets> (native);
            SetMultiProductOneStep (boost::dynamic_pointer_cast<QuantLib::MultiProductOneStep> (*_ppOneStepOptionlets));
        }
#ifdef HANDLE
		QuantLib::Handle<QuantLib::OneStepOptionlets>& GetHandle ();
#endif
		virtual bool HasNative () override;
    public:
		virtual Boolean NextTimeStep (Cephei::QL::Models::Marketmodels::ICurveState^ currentState, Cephei::IVector<UInt64>^ numberCashFlowsThisStep, Cephei::IMatrix<Cephei::QL::Models::Marketmodels::IMarketModelMultiProductCashFlow^>^ cashFlowsGenerated) ;
        property UInt64 MaxNumberOfCashFlowsPerProductPerStep 
        {
		    virtual UInt64 get () ;
        }
        property UInt64 NumberOfProducts 
        {
		    virtual UInt64 get () ;
        }
        property Cephei::IVector<Double>^ PossibleCashFlowTimes 
        {
		    virtual Cephei::IVector<Double>^ get () ;
        }
        property Cephei::QL::Models::Marketmodels::Products::Onestep::IOneStepOptionlets^ Reset 
        {
		    virtual Cephei::QL::Models::Marketmodels::Products::Onestep::IOneStepOptionlets^ get () ;
        }
    };
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Factory class
	public ref class COneStepOptionlets_Factory : public System::MarshalByRefObject,  public IOneStepOptionlets_Factory
	{
	public:
        virtual IOneStepOptionlets^ Create (Cephei::IVector<Double>^ rateTimes, Cephei::IVector<Double>^ accruals, Cephei::IVector<Double>^ paymentTimes, Cephei::IVector<Cephei::QL::IPayoff^>^ payoffs);
    };
   
/*Cephei*/ } /*QL*/ } /*Models*/ } /*Marketmodels*/ } /*Products*/ } /*Onestep */}
